from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
import base64

def encryptByAES(message, key):
    iv = key.encode('utf-8')
    aeskey = key.encode('utf-8')
    secretData = message.encode('utf-8')

    cipher = AES.new(aeskey, AES.MODE_CBC, iv)
    padded_data = pad(secretData, AES.block_size)

    encrypted = cipher.encrypt(padded_data)

    ciphertext = base64.b64encode(encrypted).decode('utf-8')
    return ciphertext

# 定义IV、密钥和明文
key = 'u2oh6Vu^HWe4_AES'
plaintext = '15973220373'

# 打印加密结果
print('Ciphertext:', encryptByAES(plaintext, key))
